CALL Statement (BASIC Procedures) ---------------------------------------------------------------------------- Action Transfers control to a BASIC SUB procedure. To invoke a non-BASIC procedure, use the CALL, CALLS statements (non-BASIC). Syntax 1 CALL name -( argumentlist)- Syntax 2 name -( argumentlist)- Remarks The CALL statement uses the following arguments. ----------------------------------------------------------------------------- Argument Description ---------------------------------------------------------------------------- name The name, limited to no more than 40 characters, of the BASIC SUB procedure being called. argumentlist The variables or constants passed Argument Description ---------------------------------------------------------------------------- argumentlist The variables or constants passed to the procedure. Arguments in the list are separated by commas. Arguments are passed by reference (which means they can be changed by the procedure). If argumentlist includes an array argument, the array is specified by the array name followed by empty parentheses. DIM IntArray(1 TO 20) . . . CALL ShellSort(IntArray()) If you omit the optional CALL keyword, you must declare the procedure in a DECLARE statement and omit the parentheses around argumentlist. For more information, see Chapter 2, "SUB and FUNCTION Procedures" in the Programmer's Guide. The CALL statement passes arguments only by reference, which means that the procedure is given the address of the argument. This allows procedures to change the argument values. Although the CALL statement does not pass arguments by value, you can simulate that by enclosing the argument in parentheses. This makes the argument an expression. (If an argument is passed by value, the procedure is given the value of the argument.) For example, the following statement calls a procedure and passes a single argument. CALL SolvePuzzle((StartValue)) Because StartValue is in parentheses, BASIC evaluates it as an expression. The result is stored in a temporary location, and the address of the temporary location is passed to the SUB procedure. Any change made by the procedure SolvePuzzle is made to the temporary location only, and not to StartValue itself. See Also Absolute Routine; CALL, CALLS (Non-BASIC); DECLARE (BASIC) Example The following example uses the CALL statement to call a SUB procedure that prints a message on the 25th line of the display. CLS' Clear screen. message$ = "The quick brown fox jumped over the lazy yellow dog." CALL PrintMessage(message$) END SUB PrintMessage (message$) LOCATE 24, 1 ' Move cursor to 25th line of display. PRINT message$; END SUB